<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
         window.onload = function() {
             var btn = document.getElementById("btn");
             btn.onclick = function() {
                 var xhr = null;
                 if(window.XMLHttpRequest){
                     xhr = new XMLHttpRequest();
                 }else{
                     xhr = new ActiveXObject("Microsoft.XMLHTTP");
                 }
                 var username = document.getElementById("username").value;
                 var password = document.getElementById("password").value;
                 var url = 'index.php?username=' + username + '&password=' + password;
//                 console.log(url);
                 xhr.open('get', url, true);
                 xhr.send(null);
                 xhr.onreadystatechange = function() {
                     if(xhr.readyState == 4){
                         if(xhr.status == 200){
                             var data = xhr.responseText;
                             console.log(data);
//                             var data = xhr.responseXML;
                         }
                     }
                 }
             }

         }
    </script>
</head>
<body>
    <form action="">
        用户名: <input type="text" id="username">
        密码： <input type="password" id="password">
        <input type="button" id="btn" value="提交">
    </form>
</body>
</html>